package com.tang.hawkmusic.fragment;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.google.gson.Gson;
import com.tang.hawkmusic.R;
import com.tang.hawkmusic.activity.BaseActivity;
import com.tang.hawkmusic.api.ApiEngine;
import com.tang.hawkmusic.api.ApiService;
import com.tang.hawkmusic.bean.SongUrl;

import java.io.IOException;
import java.util.Arrays;

import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.annotations.SchedulerSupport;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MiniPlayerFragment extends Fragment {
    private ConstraintLayout miniMainLayout;

    public MiniPlayerFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_mini_player, container, false);
        ImageView imageView=view.findViewById(R.id.imageView9);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ApiService apiService= ApiEngine.getService();
                Call<SongUrl> call=apiService.getSongUrl(new String[]{"405998841","33894312"});
                call.enqueue(new Callback<SongUrl>() {
                    @Override
                    public void onResponse(Call<SongUrl> call, Response<SongUrl> response) {
                        Gson gson=new Gson();
                        Log.d("TAG", "onResponse: ok "+gson.toJson(response.body()));
                    }

                    @Override
                    public void onFailure(Call<SongUrl> call, Throwable t) {
                        Log.d("TAG", "onResponse: fail"+t);
                    }
                });
            }
        });
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }

}